package com.example.myapplication.repository.data;

import android.util.Log;
import android.view.View;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import com.example.myapplication.BR;
import com.example.myapplication.R;

import cn.hutool.core.util.NumberUtil;

public class File extends BaseObservable {
    private String fileName;

    //大小 M
    private int size;

    // 是否为目录，0 文件、1 目录
    private int isDir;

//    文件类型，1 视频、2 音频、3 图片、4 文档、5 应用、6 其他、7 种子
    private int category;

    public String formatSize(){
        if(this.isDir == 1) return null;
        if(this.size > 1073741824){
            return NumberUtil.div(size,1024*1024*1024,2)+"GB";
        }else if(this.size > 1048576){
            return NumberUtil.div(size,1024*1024,2)+"MB";
        }else{
            return NumberUtil.div(size,1024,2)+"KB";
        }
    }

    public Object formatIcon(){
        if(isDir == 0) return R.drawable.file;
        else return R.drawable.flod;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getIsDir() {
        return isDir;
    }

    public void setIsDir(int isDir) {
        this.isDir = isDir;
    }

    public int getCategory() {
        return category;
    }

    public void setCategory(int category) {
        this.category = category;
    }


}
